package org.jeecg.modules.yw.controller;

import static org.jeecg.modules.yw.utils.CommonUtils.expireMap;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Optional;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import com.aliyuncs.exceptions.ClientException;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import org.jeecg.modules.yw.dto.EnterPriseSimpleDto;
import org.jeecg.modules.yw.entity.*;
import org.jeecg.modules.yw.result.Result;
import org.jeecg.modules.yw.service.*;
import org.jeecg.modules.yw.utils.CommonUtils;
import org.jeecg.modules.yw.utils.DESUtil;
import org.jeecg.modules.yw.utils.DateUtils;
import org.jeecg.modules.yw.utils.EncryptUtils;
import org.jeecg.modules.yw.vo.EnterPriseVo;
import org.jeecg.modules.yw.vo.ProjectWindowsVo;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;


@RestController
@RequestMapping("/app/enterpriseInfo")
@Api(tags = "门窗企业管理")
public class EnterPriseController {
    public static final int STATUS_PENDING = 0;
    public static final int STATUS_REJECTED = 2;
    @Resource
    private EnterPriseService enterPriseService;

    @Resource
    private SysAnnoucementService sysAnnoucementService;
    @Resource
    private ProjectWindowsService projectWindowsService;
    
    @Resource
    private PriceRulesService priceRuleService;
    
    @Resource
    private FlPriceService flPriceService;
    @Resource
    private ContractInfoService contractInfoService;
    @Resource
    private IWorkerCompanyRelationService workRelationService;

    @ApiOperation(value = "获取企业列表(分页)")
    @GetMapping("/getEnter")
    public org.jeecg.common.api.vo.Result page(Page<EnterPrise> page, @RequestParam(value = "mobile", required = false) String mobile) {
        LambdaQueryWrapper<EnterPrise> queryWrapper = new LambdaQueryWrapper<>();
        if (mobile != null) {
            queryWrapper.like(EnterPrise::getMobile, mobile);
        }
        queryWrapper.ne(EnterPrise::getDelflag, 1);
        queryWrapper.orderByDesc(EnterPrise::getCreatetime);

        IPage<EnterPrise> result = enterPriseService.page(page, queryWrapper);
        return org.jeecg.common.api.vo.Result.ok(result);
    }

    @ApiOperation(value = "获取企业列表(列表List)")
    @GetMapping("/getAll")
    public Result getAll(@RequestParam(value = "mobile", required = false) String mobile,
                         @RequestParam(value = "areas", required = false)String areast) {
        LambdaQueryWrapper<EnterPrise> queryWrapper = new LambdaQueryWrapper<>();
        if (mobile != null) {
            queryWrapper.like(EnterPrise::getMobile, mobile);
        }
        queryWrapper.eq(EnterPrise::getRoleid, 1);
        queryWrapper.eq(EnterPrise::getDelflag, 0);
        queryWrapper.eq(EnterPrise::getApprove, 1);
        if(StringUtils.isNotBlank(areast)){
            String[] areas=areast.split(",");
            StringBuffer st=new StringBuffer();
            for (int i = 0; i < areas.length; i++) {
                st.append("\""+areas[i]+"\",");
            }
            st=st.deleteCharAt(st.length()-1);
            String sql="(select id from enterprise where city_code in ("+st.toString()+") " +
                    "or (province_code in  ("+st.toString()+") and city_code is null))";
            queryWrapper.apply("id in"+sql);
        }
        queryWrapper.orderByDesc(EnterPrise::getCreatetime);
        List<EnterPrise> result = enterPriseService.list(queryWrapper);
        return Result.success(result);
    }
    @ApiOperation(value = "我的:查询企业信息")
    @GetMapping("/getSelfById")
    public Result getSelfById(HttpServletRequest request) {
        String token = request.getHeader("token");
        if (token == null) {
            return Result.error("未登录");
        }
        try {
            String id = DESUtil.decryptCBCId(token);
            if (id == null) {
                return Result.error("登录已过期");
            }
            EnterPrise enterPrise = enterPriseService.getById(id);
            if (enterPrise == null) {
                return Result.error("用户不存在");
            }
            EnterPriseSimpleDto dto = new EnterPriseSimpleDto();
            dto.setName(enterPrise.getName());
            dto.setSex(enterPrise.getSex());
            dto.setLinkman(enterPrise.getLinkman());
            dto.setMobile(enterPrise.getMobile());
            dto.setPicture(enterPrise.getPicture());
            dto.setAddress(enterPrise.getAddress());
            dto.setProvince(enterPrise.getProvince());
            dto.setCity(enterPrise.getCity());
            dto.setBankNo(enterPrise.getBankNo());
            dto.setBankName(enterPrise.getBankKh());
            dto.setBankStatus(enterPrise.getBankStatus());
            dto.setCityCode(enterPrise.getCityCode());
            dto.setProvinceCode(enterPrise.getProvinceCode());
            return Result.success(dto);
        } catch (Exception e) {
            System.err.println("Token 解密失败: " + e.getMessage());
            return Result.error("查询失败");
        }
    }
    //加一个修改个人信息接口
    @ApiOperation(value = "我的:修改个人信息")
    @PostMapping("/editSelfById")
    public Result editSelfById(@RequestBody EnterPriseVo enterPriseVo, HttpServletRequest request) {
        String t = request.getHeader("token");
        if (t == null) {
            return Result.error("未登录");
        }
        try {
            String id = DESUtil.decryptCBCId(t);
            EnterPrise enterPrise = enterPriseService.getById(id);
            if (enterPrise == null) {
                return Result.error("用户不存在");
            }
            UpdateWrapper<EnterPrise> updateWrapper = new UpdateWrapper<>();
            updateWrapper.set("name", enterPriseVo.getName())
                    .set("sex", enterPriseVo.getSex())
                    .set("linkman", enterPriseVo.getLinkman())
                    .set("address", enterPriseVo.getAddress())
                    .set("province",enterPriseVo.getProvince())
                    .set("province_code",enterPriseVo.getProvinceCode())
                    .set("city",enterPriseVo.getCity())
                    .set("city_code",enterPriseVo.getCityCode())
                    .set("picture", enterPriseVo.getPicture())
                    .set("bankNo", enterPriseVo.getBankNo())
                    .set("bankKh", enterPriseVo.getBankKh())
                    .set("bankStatus", enterPriseVo.getBankStatus())
                    .eq("id", id);

            enterPriseService.update(updateWrapper);
        } catch (Exception e) {
            System.err.println("Token 解密失败: " + e.getMessage());
            return Result.error("修改失败");
        }
        return Result.success(enterPriseVo);
    }

    @ApiOperation(value = "中控--通过操作")
    @GetMapping("/passById")
    public Result passById(@RequestParam(value = "id") String id) throws Exception{
        EnterPrise enterPrise = enterPriseService.getById(id);
        enterPrise.setApprove(1);
        if(enterPrise.getRoleid() == 2&&enterPrise.getIsleader()==0){
            enterPrise.setIsleader(2);
        }
        enterPrise.setApprovetime(DateUtils.getCurrentDate());
        enterPriseService.updateById(enterPrise);
        if(enterPrise.getRoleid() == 1) {
            ContractInfo contractInfo = new ContractInfo();
            contractInfo.setId(CommonUtils.getID());
            contractInfo.setEnterpriseId(id);
            contractInfo.setCreatetime(DateUtils.getCurrentDate());
            contractInfo.setCreator(enterPrise.getMobile());
            contractInfoService.save(contractInfo);
//            contractInfoService.save(new ContractInfo(id,enterPrise.getName(),enterPrise.getMobile(),enterPrise.getAddress(),enterPrise.getProvince(),enterPrise.getCity(),enterPrise.getLinkman(),enterPrise.getPicture(),"1",enterPrise.getCid(),"1"))
        	priceRuleService.insertInitiatePrice(id);
        	flPriceService.initiateFlPrice(id);
        }
        return Result.success("通过成功");
    }

    @ApiOperation(value = "中控--驳回操作")
    @GetMapping("/unpassById")
    public Result unpassById(@RequestParam(value = "id") String id,
                             @RequestParam(value = "reason",required = false) String reason) {
        EnterPrise enterPrise = enterPriseService.getById(id);
        enterPrise.setApprove(2);
        enterPrise.setReason(reason);
        enterPrise.setApprovetime(DateUtils.getCurrentDate());
        enterPrise.setDelflag("1");
        enterPriseService.updateById(enterPrise);
        return Result.success("驳回成功");
    }

    @ApiOperation(value = "中控--停用操作")
    @GetMapping("/stopById")
    public Result stopById(@RequestParam(value = "id") String id) {
        EnterPrise enterPrise = enterPriseService.getById(id);
        enterPrise.setApprove(3);
        enterPrise.setApprovetime(DateUtils.getCurrentDate());
        enterPriseService.updateById(enterPrise);
        return Result.success("停用成功");
    }

    @ApiOperation(value = "中控--安装班组/打胶售后人员选择(roleId: 1:门窗企业 , 2:安装人员, 3: 打胶售后 )")
    @GetMapping("/ryList")
    public List<EnterPrise> pageEnter(@RequestParam(name = "roleId", defaultValue = "2") Integer roleId, @RequestParam(value = "orderId", required = false) String orderId) {
        return enterPriseService.pageEnter(roleId,null, orderId);
    }

    @ApiOperation(value = "根据企业id得到材料定价规则")
    @GetMapping("/getRules")
    public Result getRules(@RequestParam(value = "id") String id) throws Exception{
        QueryWrapper<PriceRulesEnterprise> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("enterprise_id", id);
        queryWrapper.orderByAsc("type");
		List<PriceRulesEnterprise> list = priceRuleService.getAllRuleListByEnterpriseId(id);	
        return Result.success(list);
    }
    
    @ApiOperation(value = "更新材料定价规则")
    @PostMapping("/updateRules")
    public Result updateRules(@RequestBody PriceRulesEnterprise obj) throws Exception{        
    	priceRuleService.updateEnterRulePrisePrice(obj.getEnterpriseId(), obj.getEntPriceList());
        return Result.success("success");
    }
    
    
    @ApiOperation(value = "获取价格基本信息")
    @GetMapping("/getBasicPrice")
    public Result getBasicPrice(@RequestParam(value = "enterpriseId", required = false) String enterpriseId) throws Exception{        
    	FlPrice obj = flPriceService.getAllInfoByEnterpriseId(enterpriseId);
        return Result.success(obj);
    }
    
    @ApiOperation(value = "更新价格基本信息")
    @PostMapping("/updateBasicPrice")
    public Result updateBasicPrice(@RequestBody FlPrice flObj) throws Exception{    	
    	flPriceService.deleteByEnterpriseId(flObj.getEnterpriseId());
    	flPriceService.inserFPrice(flObj);
        return Result.success("success");
    }
    
    
    @ApiOperation(value = "通过id获取企业信息")
    @GetMapping("/getById")
    public Result getById(@RequestParam(value = "id", required = false) String id) {
        LambdaQueryWrapper<EnterPrise> queryWrapper = new LambdaQueryWrapper<>();
        if (id != null) {
            queryWrapper.eq(EnterPrise::getId, id);
        }
        queryWrapper.ne(EnterPrise::getDelflag, 1);
        queryWrapper.orderByDesc(EnterPrise::getCreatetime);
        EnterPrise result = enterPriseService.getById(id);
        return Result.success(result);
    }

    /*
     * 小程序注册接口
     * */
    @ApiOperation(value = "小程序注册接口 ")
    @PostMapping("/addEnterPrise")
    @ResponseBody
    public Result addEnterPrise(@RequestBody EnterPriseVo enterPriseVo) {
        Result result = checkCode(enterPriseVo);
        if (result.getData() ==null) {
            return Result.error("验证码错误");
        }
        if (StringUtils.isBlank(enterPriseVo.getCityCode())||StringUtils.isBlank(enterPriseVo.getProvinceCode())){
            return Result.error("省份或城市不能为空");
        }
        String mobile = enterPriseVo.getMobile();
        String password = enterPriseVo.getPassword();
        if (expireMap.get(mobile) == null) {
            return Result.error("验证码已失效");
        }
        if (StringUtils.isBlank(mobile) || StringUtils.isBlank(password)) {
            return Result.error("手机号或密码不能为空");
        }
        if (enterPriseService.getOne(new QueryWrapper<EnterPrise>().eq("mobile", enterPriseVo.getMobile())
                .eq("delFlag","0")) != null) {
            return Result.error("手机号已存在");
        }
        String id =CommonUtils.getID();
        enterPriseVo.setId(id);
        enterPriseVo.setPassword(EncryptUtils.md5(enterPriseVo.getPassword())); // 密码md5加密
        enterPriseVo.setDelflag("0"); // 删除标识
        enterPriseVo.setApprove(0);
        enterPriseVo.setApprovetime(null);
        enterPriseVo.setCreatetime(DateUtils.getCurrentDate()); // 创建时间
        enterPriseVo.setBankStatus(0);
        EnterPrise enterPrise = new EnterPrise();
        // 复制属性
        BeanUtils.copyProperties(enterPriseVo, enterPrise);
        // 检查并手动赋值可能未正确复制的字段
        if (enterPriseVo.getCityCode() != null) {
            enterPrise.setCityCode(enterPriseVo.getCityCode());
        }
        if (enterPriseVo.getProvinceCode() != null) {
            enterPrise.setProvinceCode(enterPriseVo.getProvinceCode());
        }
        boolean re = enterPriseService.save(enterPrise);
        Integer roleid = enterPriseVo.getRoleid();
        String workerIds = workRelationService.getWorkersByCompanyId(enterPriseVo.getId());

        if (roleid == 1) {
            sysAnnoucementService.AddSysAnnoucement("新注册账号，请审核", "用户手机号:"+mobile+",新注册账号，请审核",
                    "1", id, "0",id, null, mobile, enterPriseVo.getCityCode());
        }else if (roleid == 2) {
            sysAnnoucementService.AddSysAnnoucement("新注册账号，请审核", "用户手机号:"+mobile+",新注册账号，请审核",
                    "2", id, "0",id, null, mobile, enterPriseVo.getCityCode());
        } else if (roleid == 3) {
            sysAnnoucementService.AddSysAnnoucement("新注册账号，请审核", "用户手机号:"+mobile+",新注册账号，请审核",
                    "3", id, "0",id, null, mobile, enterPriseVo.getCityCode());
        }
        if (re) {
            expireMap.remove(mobile);
            return Result.success("添加成功");
        } else {
            return Result.error("添加失败");
        }
    }

    @ApiOperation(value = "小程序密码登录")
//    @ApiImplicitParam(name="mobile", value="手机号")
    @PostMapping("/login")
    @ResponseBody
    public Result login(@RequestBody EnterPriseVo enterPriseVo) {
        Result result = new Result();

        HashMap<String, Object> map = new HashMap<>();
        String mobile = enterPriseVo.getMobile();
        String password = enterPriseVo.getPassword();
//        String s = EncryptUtils.md5(password);
        QueryWrapper<EnterPrise> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("mobile", enterPriseVo.getMobile());
        List<EnterPrise> enterpriseList = enterPriseService.list(queryWrapper);

        EnterPrise one = null;
        if (CollectionUtils.isNotEmpty(enterpriseList)) {
            for (EnterPrise enterprise : enterpriseList) {
                if ("0".equals(enterprise.getDelflag())) {
                    one = enterprise;
                    break;
                }
            }
        }
        if (one == null) {
            return Result.error("用户不存在");
        }
        EnterPrise enterPrise = enterPriseService.login(mobile, password);
        if (enterPrise == null) {
            return Result.error("用户名或密码错误");
        }
        if (enterPrise.getApprove() == STATUS_PENDING) {
            return Result.error("账号未通过审核,请等待审核");
        }
        if (enterPrise.getApprove() == STATUS_REJECTED){
            result.setData(enterPrise.getReason());
            return Result.error("账号申请被拒绝");
        }
        if (enterPrise != null) {
            String t = enterPrise.getId();  
            // 更新refreshToken
            long now = System.currentTimeMillis();
            enterPriseService.getBaseMapper().updateToken(enterPrise.getId(), String.valueOf(now));
            t = t + "," + String.valueOf(now);          
            String token = DESUtil.encryptCBC(t);
            map.put("token", token);
            map.put("roleid", enterPrise.getRoleid());
            map.put("province",enterPrise.getProvince());
            map.put("provinceCode",enterPrise.getProvinceCode());
            map.put("cityCode",enterPrise.getCityCode());
            map.put("city",enterPrise.getCity());
            map.put("name", enterPrise.getName());
            map.put("picture",enterPrise.getPicture());
            Integer isLeaderValue = Optional.ofNullable(enterPrise.getIsleader()).orElse(0);
            map.put("isLeader", isLeaderValue);
            map.put("bankStatus", enterPrise.getBankStatus());

            result.setCode(0);
            result.setMsg("登录成功");
            result.setData(map);
            return result;
        } else {
            return Result.error("登录失败");
        }
    }
    @ApiOperation("退出登录")
    @GetMapping("/logout")
    public Result logout(HttpServletRequest request) {
        HttpSession session = request.getSession(false);
        if (session != null) {
            session.invalidate();
        }
        return Result.success("退出成功");
//        String token = request.getHeader("token");
//        if (StringUtils.isNotBlank(token)) {
//
////            redisTemplate.delete(CommonConstant.PREFIX_USER_TOKEN + token);
////            redisTemplate.delete(CommonConstant.PREFIX_USER_SHIRO_CACHE + token);
//            return Result.success("退出成功");
//        } else {
//            return Result.error("退出失败");
//        }
    }

    @ApiOperation(value = "中控--修改企业信息")
    @PostMapping("/editEnterPrise")
    @ResponseBody
    public Result editEnterPrise(@RequestBody EnterPriseVo enterPriseVo) {
        String id = enterPriseVo.getId();
        QueryWrapper queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id", id);
        EnterPrise enterPrise = enterPriseService.getOne(queryWrapper);
        BeanUtils.copyProperties(enterPriseVo, enterPrise);
        boolean b = enterPriseService.updateById(enterPrise);
        if (b) {
            return Result.success("修改成功");
        } else {
            return Result.error("修改失败");
        }
    }

    @ApiOperation(value = "删除企业")
    @GetMapping("/deleteEnterPrise")
    public Result deleteEnterPrise(@RequestParam(value = "id") String id) {
        EnterPrise enterPrise = enterPriseService.getById(id);
        enterPrise.setDelflag("1");
        boolean b = enterPriseService.updateById(enterPrise);
        if (b) {
            System.out.println(Result.success("删除成功"));
            return Result.success("删除成功");
        } else {
            return Result.error("删除失败");
        }
    }

    @ApiOperation(value = "重置密码")
    @PostMapping("/resetPassword")
    public Result resetPassword(@RequestBody EnterPriseVo enterPriseVo) {    	   	
        String password = enterPriseVo.getPassword();
        String confirmpassword = enterPriseVo.getConfirmpassword();
        
        String mobile =  enterPriseVo.getMobile();
        String oldpassword = enterPriseService.getPaswordByMobile(mobile);    
        if (!password.equals(confirmpassword)) {
            return Result.error("两次密码不一致");
        }        
        if (confirmpassword.equals(oldpassword)) {
        	 return Result.error("新密码不能和旧密码一致");
        }        
        String id = enterPriseService.getIdByMobile(mobile);
        if (StringUtils.isBlank(id)) {
       	  return Result.error("该用户未注册，请先注册");
        } 
        EnterPrise enterPrise = enterPriseService.getById(id);
        enterPrise.setPassword(password);
        boolean b = enterPriseService.updateById(enterPrise);
        if (b) {
            return Result.success("重置密码成功");
        } else {
            return Result.error("重置密码失败");
        }
    }

    @ApiOperation(value = "修改密码")
    @PostMapping("/editPassword")
    public Result editPassword(@RequestBody EnterPriseVo enterPriseVo) {
        String password = enterPriseVo.getPassword();
        String confirmpassword = enterPriseVo.getConfirmpassword();
        if (!password.equals(confirmpassword)) {
            return Result.error("两次密码不一致");
        }
        String id = enterPriseVo.getMobile();
        EnterPrise enterPrise = enterPriseService.getById(id);
        enterPrise.setPassword(EncryptUtils.md5(password));
        boolean b = enterPriseService.updateById(enterPrise);
        if (b) {
            return Result.success("修改密码成功");
        } else {
            return Result.error("修改密码失败");
        }
    }

    @ApiOperation(value = "发送验证码")
    @PostMapping("/sendCode")
    public Result sendCode(@RequestBody EnterPriseVo enterPriseVo) throws ClientException {
        String mobile = enterPriseVo.getMobile();
        int validPhoneNumber = CommonUtils.isValidPhoneNumber(mobile);
        if (validPhoneNumber == 0) {
            return Result.error("手机号格式错误");
        }
        String code = CommonUtils.get6bitString();
//        String code = "123456";
        expireMap.put(mobile, code);
        String s = CommonUtils.sendSMS(mobile, code);
        if (s.equals("OK")){
            return Result.success("验证码已经发送,五分钟内有效,请注意查收");
        }else {
            return Result.error("验证码发送失败");
        }
    }

    @ApiOperation(value = "检查验证码")
    @PostMapping("/checkCode")
    public Result checkCode(@RequestBody EnterPriseVo enterPriseVo) {
        String mobile = enterPriseVo.getMobile();
        String code = enterPriseVo.getCode();
        if (expireMap.get(mobile) == null) {
            return Result.error("验证码已过期");
        }
        String s = expireMap.get(mobile);
        if (s.equals(code)) {
            return Result.success("true");
        } else {
            return Result.error("false");
        }
    }
    @ApiOperation(value = "工程窗邀约")
    @PostMapping("/inviteProject")
    public Result inviteProject(@RequestBody ProjectWindowsVo projectWindowsVo, HttpServletRequest request) {
        String t = request.getHeader("token");
        String id = DESUtil.decryptCBCId(t);
        if (id == null) {
            return Result.error("未登录");
        }
        if (StringUtils.isBlank(projectWindowsVo.getName())||StringUtils.isBlank(projectWindowsVo.getAddress())||
                StringUtils.isBlank(projectWindowsVo.getPhone())||StringUtils.isBlank(projectWindowsVo.getTalkTime())){
            return Result.error("参数错误");
        }
        EnterPrise enterPrise = enterPriseService.getById(id);
        if (enterPrise.getRoleid() != 1){
            return Result.error("您不是门窗安装组人员，无法预约量尺");
        }
        ProjectWindows p = new ProjectWindows();
        Date tal = DateUtils.strToDateTime(projectWindowsVo.getTalkTime());
        p.setId(CommonUtils.getID());
        p.setEnterpriseId(id);
        p.setName(projectWindowsVo.getName());
        p.setAddress(projectWindowsVo.getAddress());
        p.setPhone(projectWindowsVo.getPhone());
        p.setTalkTime(DateUtils.dateToStr(tal));
        boolean b = projectWindowsService.saveOrUpdate(p);
        String workerIds = workRelationService.getWorkersByCompanyId(id);
        sysAnnoucementService.AddSysAnnoucement("工程洽谈消息", "用户手机号:"+enterPrise.getMobile()+",工程洽谈",
                "20", id, workerIds,id, null, p.getId(), enterPrise.getCityCode());
        if (!b){
            return Result.error("发送失败,请检查信息");
        }
        return Result.success("发送成功");
    }
    
    
    @ApiOperation(value = "加入企业价格测试")
    @GetMapping("/addPriceTest")
    public Result addPriceTest(@RequestParam(value = "id") String id) throws Exception {
		 priceRuleService.insertInitiatePrice(id);
         return Result.error("success");
    }



}
